<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../../images/favicon.ico">

  <include file="Public/header" />
  <style type="text/css" media="screen">
    .ace-editor { 
      min-height: 600px;
    }
  </style>
  <!-- Main Navbar -->
 <div class="main-nav">   
     <nav class="navbar navbar-expand-lg">
          <div class="collapse navbar-collapse" id="navbarNavDropdown">
            <ul class="navbar-nav">
              <li class="nav-item ">
                <a class="nav-link" href="/admin.php"><span class="active-item-here"></span><i class="fa fa-dashboard mr-5"></i> <span>仪表盘</span></a>
              </li>
              <li class="nav-item dropdown active">

                <a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                  <i class="fa fa-th mr-5"></i> <span class="active-item-here"></span><span>应用中心</span>
                </a>                  
                <ul class="dropdown-menu multilevel scale-up-left">
                  <li class="nav-item"><a class="nav-link" href="{:U('tools/index')}">应用管理</a></li>
                  <li class="nav-item"><a class="nav-link active" href="{:U('tools/add')}">新增应用</a></li>     
                  <li class="nav-item"><a class="nav-link" href="{:U('tools/classe')}">分类管理</a></li> 
                  <li class="nav-item"><a class="nav-link" href="{:U('tools/link')}">友链管理</a></li>
                  <li class="nav-item"><a class="nav-link" href="{:U('tools/menu')}">导航管理</a></li>            
                </ul>                 
              </li> 
              
              <li class="nav-item dropdown m-menu m-fix">
                <a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                  <i class="fa fa-table mr-5"></i> <span>系统设置</span>
                </a>
                <div class="dropdown-menu menu-mega mega-menu-auto scale-up-left">
                    <ul class="dropdown-menu multilevel scale-up-left">
                        <li>
                            <a class="nav-link" href="{:U('system/index')}" title=""><i class="fa fa-creative-commons mr-15"></i>基础设置</a>
                        </li>
                        <li>
                            <a class="nav-link" href="{:U('system/upinfo')}" title=""><i class="fa fa-address-card-o mr-15"></i>信息修改</a>
                        </li>
                        <li>
                            <a class="nav-link" href="{:U('system/temp')}" title=""><i class="fa fa-cubes mr-15"></i>模板设置</a>
                        </li>
                       <!--  -->
                    </ul><!-- /.menu-mega-child one-four -->
                          
                    
                </div>
                  
              </li>
              
              <li class="nav-item dropdown m-menu">
                <a class="nav-link" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                  <i class="fa fa-laptop mr-5"></i> <span>应用商店</span>
                </a>
                <div class="dropdown-menu menu-mega scale-up-down">
                  
                    
                </div>
                  
              </li>               
              <li class="nav-item dropdown">
                <a class="nav-link" href="{:U('update/index')}">
                  <i class="fa fa-puzzle-piece mr-5"></i>检查更新
                </a>
              </li>
               
            </ul>
          </div>
        </nav>      
  </div>

  

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        首页文件编辑
      </h1>
      <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href="/admin.php"><i class="fa fa-dashboard"></i> 仪表盘</a></li>
        <li class="breadcrumb-item"><a href="{:U('tools/index')}">应用管理</a></li>
        <li class="breadcrumb-item active">首页文件编辑</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
     
      <!-- Example Javascript Mode -->
      
      <!-- /.box -->
      
      <!-- Example Html Mode And Emmet Mode -->
      <div class="box">
        <div class="box-header with-border">
          <h4 class="box-title">编辑你首页的文件</h4>
          <h6 class="box-subtitle">本编辑器默认打开当前应用目录下的<code>index.php</code>和<code>index.html</code>文件，如目录下同时存在<code>index.php</code>和<code>index.html</code>文件，则默认打开<code>index.html</code>文件</h6>
        
        </div>
        <!-- /.box-header -->
        <div class="box-body">
          
          <pre class="ace-editor" id="editorHTML" data-plugin="ace" data-mode="html"
              style="width: 100%;">{$code}</pre>          
      </div>
        <!-- /.box-body -->
        <div class="box-footer">
                <a href="{:U('tools/index')}" class="btn btn-default"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">取消</font></font></a>
                <button type="button" id="updata" class="btn btn-info pull-right"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">修改</font></font></button>
              </div>
      </div>
      <!-- /.box -->
      
      <!-- Example Css Mode -->
      
      <!-- /.box -->
      
      
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
  
   <include file="Public/footer" />
  
  <!-- Fab admin horizontal-layout -->
  <script src="__PUBLIC__/Admin/js/horizontal-layout.js"></script>
  
  <!-- ace-editor --> 
  <script src="__PUBLIC__/Admin/vendor_plugins/ace-builds-master/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
  <script src="__PUBLIC__/Admin/js/layer/layer.js"></script>
  <script>
    

    var editor = ace.edit("editorHTML");
    editor.setTheme("ace/theme/solarized_light");
    editor.getSession().setMode("ace/mode/html");

   
  </script>
  <script type="text/javascript">
      $("#updata").click(function(){
        var e =0;
        var editor = ace.edit("editorHTML");
        var data = editor.getValue();
        var filepath = '{$filepath}';
        var index = layer.load(1, {shade: false}); //0代表加载的风格，支持0-2
        if (e == 0) {
            $.post("{:U('tools/upindexdata')}", {data:data,filepath:filepath}, function (data) {
              var index = layer.load(1, {shade: false}); //0代表加载的风格，支持0-2
                if (data.status == '1') {
                  layer.closeAll('loading');
                    layer.alert(data.info, { icon: 6 });//layer.msg('不开心。。', {icon: 5});
                    window.location.href = data.url;
                } else {
                  layer.closeAll('loading');
                    layer.alert(data.info, { icon: 5 });
                }
            })
        }
        
      
    });
  </script>
</body>
</html>
